
#Load the types and object into the module
Add-Type -Path "$PSScriptRoot\bin\log4net.dll" -ErrorAction 'Continue'
Add-Type -Path "$PSScriptRoot\bin\PoshLoggerInfo.cs" -ErrorAction 'Continue'
. "$PSScriptRoot\Logger.ps1"

#Create an instance of PoshLoggerInfo and setup the properties
$PoshLoggerInfo = New-Object PoshLogger.PoshLoggerInfo
$PoshLoggerInfo.DefaultLogger = Get-Logger -Name 'PoshLogger' -FileLog -EventLog -ConsoleLog -Level "INFO" -Force
Add-Member -InputObject $PoshLoggerInfo -MemberType NoteProperty -Name 'NativeWriteHost' -Value ( Get-Command -CommandType Cmdlet -Name Write-Host -Module Microsoft.PowerShell.Utility ) -Force

#Create an Alias to hide native Write-Host
Set-Alias -Name 'Write-Host' -Value ( Get-Command -CommandType Function -Name "Write*Info" -Module PoshLogger -TotalCount 1 ) -Force

#Release the hounds
Export-ModuleMember -Alias 'Write-Host' -Variable 'PoshLoggerInfo' -Function "*Logger","*LogContext","Write*"